package com.ruoyi.jobservice.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jobservice.domain.SSoldierJobInfo;
import com.ruoyi.jobservice.service.ISSoldierJobInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 退役军人就业创业信息Controller
 * 
 * @author jeffery
 * @date 2021-08-31
 */
@RestController
@RequestMapping("/jobservice/job")
public class SSoldierJobInfoController extends BaseController
{
    @Autowired
    private ISSoldierJobInfoService sSoldierJobInfoService;

    /**
     * 查询退役军人就业创业信息列表
     */
    @PreAuthorize("@ss.hasPermi('jobservice:job:list')")
    @GetMapping("/list")
    public TableDataInfo list(SSoldierJobInfo sSoldierJobInfo)
    {
        startPage();
        List<SSoldierJobInfo> list = sSoldierJobInfoService.selectSSoldierJobInfoList(sSoldierJobInfo);
        return getDataTable(list);
    }

    /**
     * 导出退役军人就业创业信息列表
     */
    @PreAuthorize("@ss.hasPermi('jobservice:job:export')")
    @Log(title = "退役军人就业创业信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SSoldierJobInfo sSoldierJobInfo)
    {
        List<SSoldierJobInfo> list = sSoldierJobInfoService.selectSSoldierJobInfoList(sSoldierJobInfo);
        ExcelUtil<SSoldierJobInfo> util = new ExcelUtil<SSoldierJobInfo>(SSoldierJobInfo.class);
        return util.exportExcel(list, "退役军人就业创业信息数据");
    }

    /**
     * 获取退役军人就业创业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('jobservice:job:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sSoldierJobInfoService.selectSSoldierJobInfoById(id));
    }

    /**
     * 新增退役军人就业创业信息
     */
    @PreAuthorize("@ss.hasPermi('jobservice:job:add')")
    @Log(title = "退役军人就业创业信息", businessType = BusinessType.INSERT)
    @PostMapping(value = "addSoldierJobInfo")
    public AjaxResult add(@RequestBody SSoldierJobInfo sSoldierJobInfo)
    {
        return toAjax(sSoldierJobInfoService.insertSSoldierJobInfo(sSoldierJobInfo));
    }

    /**
     * 修改退役军人就业创业信息
     */
    @PreAuthorize("@ss.hasPermi('jobservice:job:edit')")
    @Log(title = "退役军人就业创业信息", businessType = BusinessType.UPDATE)
    @PostMapping(value = "editSoldierJobInfo")
    public AjaxResult edit(@RequestBody SSoldierJobInfo sSoldierJobInfo)
    {
        return toAjax(sSoldierJobInfoService.updateSSoldierJobInfo(sSoldierJobInfo));
    }

    /**
     * 删除退役军人就业创业信息
     */
    @PreAuthorize("@ss.hasPermi('jobservice:job:remove')")
    @Log(title = "退役军人就业创业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sSoldierJobInfoService.deleteSSoldierJobInfoByIds(ids));
    }

    @GetMapping(value = "/getSoldierMessage")
    public AjaxResult getSoldierMessage(String idNumber)
    {
        return sSoldierJobInfoService.getSoldierMessage(idNumber);
    }
}
